package com.syt.cellphone.information.ui.phone.details

import android.annotation.SuppressLint
import android.content.Context
import com.bumptech.glide.Glide
import com.syt.cellphone.information.R
import com.syt.cellphone.information.base.adapter.ItemViewHolder
import com.syt.cellphone.information.base.adapter.SimpleRecyclerAdapter
import com.syt.cellphone.information.data.pojo.Estimate
import kotlinx.android.synthetic.main.item_estimate.view.*
import java.text.SimpleDateFormat

/**
 *  @author: syt
 *  创建时间: 2020/9/9 16:46
 *  @功能   评价适配器
 *  @version v1.0
 */
class EstimateAdapter(context: Context, var callBack: CallBack) :
    SimpleRecyclerAdapter<Estimate>(context, R.layout.item_estimate) {

    @SuppressLint("SimpleDateFormat")
    override fun convert(holder: ItemViewHolder, item: Estimate, payloads: MutableList<Any>) {
        holder.itemView.apply {
            tv_item_estimate_model.text = item.model
            tv_item_estimate_time.text = SimpleDateFormat("yyyy-MM-dd").format(item.estimateTime)
            tv_item_estimate_content.text = item.estimateComment
            Glide.with(context).load(item.userPortrait).into(iv_item_estimate_head)
        }
    }

    override fun registerListener(holder: ItemViewHolder) {

    }

    // 预留的回调函数，点击头像，点击评价都可以用到。
    interface CallBack {

    }
}